home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7008 < prev    next >
Encoding:
Text File  |  1996-08-05  |  908 b   |  47 lines

  1. Path: news.epix.net!usenet
  2. From: jgvd@epix.net (Jon)
  3. Newsgroups: comp.lang.c++
  4. Subject: A simple "find the bug" (please! I need help :)
  5. Date: 21 Feb 1996 01:06:31 GMT
  6. Organization: epix.net
  7. Message-ID: <4gdr6n$6p0@guava.epix.net>
  8. NNTP-Posting-Host: pclkppp63.epix.net
  9. Mime-Version: 1.0
  10. X-Newsreader: WinVN 0.93.14
  11.  
  12. I wrote this just now and it's telling me that when i try to cout the 
  13. result at the bottom, it is an undefined value even though I did return 
  14. the result var...  See if you can help.
  15.  
  16. #include <iostream.h>
  17.  
  18. float num1;
  19. float num2;
  20.  
  21. getnums () {
  22.  
  23. float result = num1 +num2;
  24.  
  25. cout << "What number?\n";
  26. cin >> num1;
  27. cout << "And?\n";
  28. cin >> num2;
  29.  
  30. return result;
  31. }
  32.  
  33. main (){
  34.  
  35. getnums ();
  36.  
  37.  
  38. cout << result;
  39. }
  40.  
  41.         ^^^^^^ right there is the result i want printed but it does not 
  42. recognize it even though I did try to return the value in the function 
  43. getnums... am I missing something?
  44.  
  45. Jon
  46.  
  47.